﻿Imports System.Data.SqlServerCe
Imports Framework.Data

Namespace Backup
    Public Class ReceivedContracts
        Shared Sub New()
            Dim aSelectColumns As String() = {"Id", "IssuedByBuddyId", "StorageSize", "Comment", "Revoked"}
            ObjectPersister.DefineObject(GetType(Entities.Backup.ReceivedContract), "BackupReceivedContracts", aSelectColumns)
        End Sub
        Private Sub New()
        End Sub

        Public Shared Function GetAll() As Generic.List(Of Entities.Backup.ReceivedContract)
            Return ObjectPersister.GetAll(Of Entities.Backup.ReceivedContract)()
        End Function
        Public Shared Function GetById(ByVal id As Integer) As Entities.Backup.ReceivedContract
            Dim strClause As String = "Id=@Id"
            Dim sqlPar1 As New SqlCeParameter("@Id", id)
            Return ObjectPersister.GetOne(Of Entities.Backup.ReceivedContract)(strClause, sqlPar1)
        End Function
        Public Shared Function GetByUniqueId(ByVal uniqueId As String) As Entities.Backup.ReceivedContract
            Dim strClause As String = "UniqueId=@UniqueId"
            Dim sqlPar1 As New SqlCeParameter("@UniqueId", uniqueId)
            Return ObjectPersister.GetOne(Of Entities.Backup.ReceivedContract)(strClause, sqlPar1)
        End Function

        Public Shared Sub Save(ByVal contract As Entities.Backup.ReceivedContract)
            Dim clsCmd As New SaveCommand(Of Integer)("BackupReceivedContracts", "Id", contract.Id, 0)
            clsCmd.AddParam("UniqueId", contract.UniqueId, False)
            clsCmd.AddParam("Comment", contract.Comment, False)
            clsCmd.AddParam("IssuedByBuddyId", contract.IssuedByBuddyId, False)
            clsCmd.AddParam("Revoked", contract.Revoked, False)
            clsCmd.AddParam("StorageSize", contract.StorageSize, False)

            clsCmd.Save()
        End Sub

    End Class
End Namespace